function JCIBlockGenerator(e){if(!e)return;this.intERROR=0;this.intIMAGE_ROW_ID=0;this.PREFIX=e.PREFIX;this.PREFIX_TR=this.PREFIX+"ROW_";this.PROP_COUNT_ID=e.PROP_COUNT_ID;this.TABLE_PROP_ID=e.TABLE_PROP_ID;this.AR_ALL_PROPERTIES=e.AR_ALL_PROPERTIES;this.AR_FILE_PROPERTIES=e.AR_FILE_PROPERTIES;this.IMAGE_TABLE_ID=e.IMAGE_TABLE_ID;this.CELLS=[];this.CELL_CENT=[];this.PROPERTY_MAP=[];this.CHECKED_MAP=[];this.SELECTED_PROPERTIES=[];this.lockProperties=false;BX.ready(BX.proxy(this.Init,this))}JCIBlockGenerator.prototype.Init=function(){var e,t,a;this.PROP_TBL=BX(this.TABLE_PROP_ID);if(!this.PROP_TBL){this.intERROR=-1;return}this.PROP_COUNT=BX(this.PROP_COUNT_ID);if(!this.PROP_COUNT){this.intERROR=-1;return}for(e=0;e<this.AR_ALL_PROPERTIES.length;e++){t=[];if(this.AR_ALL_PROPERTIES[e].hasOwnProperty("VALUE")){for(a=0;a<this.AR_ALL_PROPERTIES[e]["VALUE"].length;a++)t[this.AR_ALL_PROPERTIES[e]["VALUE"][a]["ID"]]=this.AR_ALL_PROPERTIES[e]["VALUE"][a]["VALUE"]}this.PROPERTY_MAP[this.AR_ALL_PROPERTIES[e]["ID"]]=t;this.CHECKED_MAP[this.AR_ALL_PROPERTIES[e]["ID"]]=[]}};JCIBlockGenerator.prototype.addPropertyTable=function(e){if(0>this.intERROR||BX("property_table"+e))return;this.PROP_TBL=BX(this.TABLE_PROP_ID);var t=Number(BX("generator_property_table_max_id").value);if(t&&t<this.AR_ALL_PROPERTIES.length&&t>0){this.PROP_TBL.appendChild(BX.create("div",{props:{id:"property_separator_"+e,className:"adm-shop-table-increase"}}))}var a=BX.create("div",{props:{id:"property_td_"+e,className:"adm-shop-table-wrap"},style:{verticalAlign:"top"},children:[BX.create("table",{props:{className:"adm-shop-table",id:"property_table"+e},children:[BX.create("tr",{props:{className:"adm-shop-table-title"},children:[BX.create("td",{props:{className:"adm-shop-table-cell"},children:[BX.create("span",{text:this.AR_ALL_PROPERTIES[e]["NAME"]})]}),BX.create("td",{props:{className:"adm-shop-table-cell"}}),BX.create("td",{props:{className:"adm-shop-table-cell"},children:[BX.create("span",{props:{className:"adm-shop-del-btn"},events:{click:function(t){return function(){t.deleteTd(e)}}(this)}})]})]}),BX.create("tr",{props:{className:"adm-shop-table-header"},children:[BX.create("td",{props:{className:"adm-shop-table-cell"},children:[BX.create("span",{text:BX.message("IB_SEG_TITLE")})]}),BX.create("td",{props:{className:"adm-shop-table-cell"},children:[BX.create("span",{text:BX.message("IB_SEG_SORT")})]}),BX.create("td",{props:{className:"adm-shop-table-cell"},children:[BX.create("input",{props:{type:"checkbox",id:"checked_all_"+e,checked:false,className:"adm-designed-checkbox"},events:{click:function(t){return function(){t.checkboxManage(this,e)}}(this)}}),BX.create("label",{props:{className:"adm-designed-checkbox-label",htmlFor:"checked_all_"+e}})]})]})]})]});this.PROP_TBL.appendChild(a);BX("generator_property_table_max_id").value=Number(BX("generator_property_table_max_id").value)+1;this.AR_ALL_PROPERTIES[e]["USE"]="N";this.CHECKED_MAP[this.AR_ALL_PROPERTIES[e]["ID"]]=[];if(BX("property_table"+e)&&this.AR_ALL_PROPERTIES[e]["VALUE"]){for(var i=0;i<this.AR_ALL_PROPERTIES[e]["VALUE"].length;i++){BX("property_table"+e).appendChild(BX.create("tr",{children:[BX.create("td",{props:{className:"adm-shop-table-cell"},children:[BX.create("span",{text:this.AR_ALL_PROPERTIES[e]["VALUE"][i]["VALUE"]}),BX.create("input",{props:{type:"hidden",id:"property_value_"+e,name:"PROPERTY_VALUE["+this.AR_ALL_PROPERTIES[e]["VALUE"][i]["PROPERTY_ID"]+"]["+this.AR_ALL_PROPERTIES[e]["VALUE"][i]["ID"]+"]",value:this.AR_ALL_PROPERTIES[e]["VALUE"][i]["ID"]}})]}),BX.create("td",{props:{className:"adm-shop-table-cell"},children:[BX.create("span",{text:this.AR_ALL_PROPERTIES[e]["VALUE"][i]["SORT"]})]}),BX.create("td",{props:{className:"adm-shop-table-cell"},children:[BX.create("input",{props:{type:"checkbox",id:"PROPERTY_CHECK_"+this.AR_ALL_PROPERTIES[e]["VALUE"][i]["PROPERTY_ID"]+"_"+i,checked:false,name:"PROPERTY_CHECK["+this.AR_ALL_PROPERTIES[e]["VALUE"][i]["PROPERTY_ID"]+"]["+this.AR_ALL_PROPERTIES[e]["VALUE"][i]["ID"]+"]",className:"adm-designed-checkbox property_value_checkbox"+e},events:{change:function(e){return function(){e.checkboxMapManage(this)}}(this)}}),BX.create("label",{props:{className:"adm-designed-checkbox-label",htmlFor:"PROPERTY_CHECK_"+this.AR_ALL_PROPERTIES[e]["VALUE"][i]["PROPERTY_ID"]+"_"+i}})]})]}))}}};JCIBlockGenerator.prototype.deleteTd=function(e){var t=BX("property_td_"+e),a=BX("property_table"+e).parentNode.previousSibling,i=BX("property_table"+e).parentNode.nextSibling;if(a)var r=BX("property_table"+e).parentNode.previousSibling.className=="adm-shop-table-increase";if(i)var s=BX("property_table"+e).parentNode.nextSibling.className=="adm-shop-table-increase";if(t){this.AR_ALL_PROPERTIES[e]["USE"]="N";delete this.CHECKED_MAP[this.AR_ALL_PROPERTIES[e]["ID"]];if(r)a.parentNode.removeChild(a);else if(s)i.parentNode.removeChild(i);t.parentNode.removeChild(t);BX("generator_property_table_max_id").value=Number(BX("generator_property_table_max_id").value)-1}};JCIBlockGenerator.prototype.loadAllProperties=function(){var e,t;if(!this.lockProperties){for(var a=0;a<this.AR_ALL_PROPERTIES.length;a++){if(e=BX("property_table"+a)){for(var i=0;i<e.children.length;i++){t=e.children[i].getElementsByTagName("input")}}this.addPropertyTable(a)}}};JCIBlockGenerator.prototype.checkboxManage=function(e,t){var a=document.getElementsByClassName("property_value_checkbox"+t),i;this.AR_ALL_PROPERTIES[t]["USE"]=e.checked?"Y":"N";if(a){for(i=0;i<a.length;i++){a[i].checked=e.checked;this.checkboxMapManage(a[i])}}};JCIBlockGenerator.prototype.checkboxMapManage=function(e){var t=e.name;var a=e.className;var i=document.getElementsByClassName(a);var r=/\[([0-9a-zA-Z]+)\]/g;var s=/([0-9]+)/g;var _=t.match(r)[0].match(/[0-9a-zA-Z]+/g)[0];var o=t.match(r)[1].match(/[0-9a-zA-Z]+/g)[0];var l=a.match(s);var n=0;if(e.checked){this.CHECKED_MAP[_][o]="Y";this.AR_ALL_PROPERTIES[l]["USE"]="Y"}else{for(var E in i){if(i.hasOwnProperty(E))if(i[E].type=="checkbox"&&!i[E].checked)n++}if(n==i.length){this.AR_ALL_PROPERTIES[l]["USE"]="N"}delete this.CHECKED_MAP[_][o]}};JCIBlockGenerator.prototype.addPropertyImages=function(){this.disableControls();var e={PROPERTY_CHECK:this.CHECKED_MAP,PROPERTY_VALUE:this.PROPERTY_MAP,AJAX_MODE:"Y",sessid:BX.bitrix_sessid()};BX.showWait("ib_seg_add_images_button");BX.ajax.post("/bitrix/admin/iblock_subelement_generator.php",e,BX.proxy(this.fPropertyImagesResult,this))};JCIBlockGenerator.prototype.fPropertyImagesResult=function(result){BX.closeWait();if(result.length>0){if(!BX("image_table_thead"))this.addImageTableHead();else BX("image_table_thead").style.display="table-row";var objMap=eval(result);this.addImageTableRow(objMap)}};JCIBlockGenerator.prototype.addImageTableHead=function(){var e=BX(this.IMAGE_TABLE_ID),t=e.appendChild(BX.create("tr",{props:{id:"image_table_thead",className:"heading"},children:[BX.create("td")]})),a=[];for(var i=0;i<this.AR_ALL_PROPERTIES.length;i++){if(this.AR_ALL_PROPERTIES[i].hasOwnProperty("VALUE")&&typeof this.AR_ALL_PROPERTIES[i]=="object"&&this.AR_ALL_PROPERTIES[i]!==null&&this.AR_ALL_PROPERTIES[i]["USE"]!=="N"){t.appendChild(BX.create("td",{text:this.AR_ALL_PROPERTIES[i]["NAME"]}))}}for(var r in this.SELECTED_PROPERTIES){if(!this.SELECTED_PROPERTIES.hasOwnProperty(r))continue;if(BX.util.in_array(this.SELECTED_PROPERTIES[r],a))continue;if(this.SELECTED_PROPERTIES[r]=="DETAIL"){t.appendChild(BX.create("td",{text:BX.message("IB_SEG_DETAIL")}))}if(this.SELECTED_PROPERTIES[r]=="ANNOUNCE"){t.appendChild(BX.create("td",{text:BX.message("IB_SEG_ANNOUNCE")}))}for(var s in this.AR_FILE_PROPERTIES){if(this.AR_FILE_PROPERTIES.hasOwnProperty(s)){if(this.AR_FILE_PROPERTIES[s]["ID"]==this.SELECTED_PROPERTIES[r]){t.appendChild(BX.create("td",{text:this.AR_FILE_PROPERTIES[s]["NAME"]}))}}}a[a.length]=this.SELECTED_PROPERTIES[r]}};JCIBlockGenerator.prototype.addImageTableRow=function(e){var t=BX(this.IMAGE_TABLE_ID),a,i=[],r,s;for(r in e){if(e.hasOwnProperty(r))s=e[r]}this.intIMAGE_ROW_ID=0;if(BX("ib_seg_max_image_row_id")){this.intIMAGE_ROW_ID=BX("ib_seg_max_image_row_id").value;BX("ib_seg_max_image_row_id").value=Number(BX("ib_seg_max_image_row_id").value)+1}if(BX("image_table_tbody"))a=BX("image_table_tbody");else a=t.appendChild(BX.create("tbody",{props:{id:"image_table_tbody"}}));var _=a.appendChild(BX.create("tr",{props:{id:"ib_seg_image_row_"+this.intIMAGE_ROW_ID,className:"ib_seg_image_row"}}));_.appendChild(BX.create("td",{children:[BX.create("div",{props:{className:"adm-shop-del-btn"},style:{marginLeft:"5px"},events:{click:function(){return function(){var e=this.parentNode.parentNode;e.style.display="none";e.className+="_hidden";var t=e.getElementsByTagName("select");for(var a in t){if(t.hasOwnProperty(a)&&!isNaN(a)){t[a].appendChild(BX.create("OPTION",{props:{value:-2},text:"-2"}));t[a].value=-2}}var i=BX("image_table_tbody").querySelectorAll("tr.ib_seg_image_row");if(i.length==0&&BX("image_table_thead")){BX("image_table_thead").style.display="none"}}}()}})]}));for(var o=0;o<this.AR_ALL_PROPERTIES.length;o++){if(this.AR_ALL_PROPERTIES[o].hasOwnProperty("VALUE")&&typeof this.AR_ALL_PROPERTIES[o]=="object"&&this.AR_ALL_PROPERTIES[o]!==null&&this.AR_ALL_PROPERTIES[o]["USE"]!=="N"){r=this.AR_ALL_PROPERTIES[o].ID;if(typeof s[r]!=="undefined"){var l=[BX.create("OPTION",{props:{value:-1},text:BX.message("IB_SEG_FOR_ALL")})];for(var n in s[r]){if(s[r].hasOwnProperty(n)){l[l.length]=BX.create("OPTION",{props:{value:n},text:s[r][n]})}}_.appendChild(BX.create("td",{children:[BX.create("span",{props:{className:"adm-select-wrap"},children:[BX.create("select",{props:{className:"adm-select",name:"PROP["+r+"]["+this.intIMAGE_ROW_ID+"]",id:"PROP["+r+"]["+this.intIMAGE_ROW_ID+"]"},style:{width:"130px"},children:l})]})]}))}}}for(r in this.SELECTED_PROPERTIES){if(!this.SELECTED_PROPERTIES.hasOwnProperty(r))continue;if(BX.util.in_array(this.SELECTED_PROPERTIES[r],i))continue;this.fIblockInputGet(this.SELECTED_PROPERTIES[r]);i[i.length]=this.SELECTED_PROPERTIES[r]}};JCIBlockGenerator.prototype.fIblockInputResult=function(e){var t=Math.random();var a=BX("ib_seg_image_row_"+this.intIMAGE_ROW_ID).appendChild(BX.create("td",{props:{id:"ib_seg_image_td_"+this.intIMAGE_ROW_ID+"_"+t}}));a.innerHTML=e;if(BX("ib_seg_image_td_"+this.intIMAGE_ROW_ID+"_"+t).firstChild){BX.bind(BX("ib_seg_image_td_"+this.intIMAGE_ROW_ID+"_"+t).firstChild,"click",BX.proxy(function(e){BX("bx_admin_form").parentNode.scrollTop+=60},this))}};JCIBlockGenerator.prototype.fIblockInputGet=function(e){var t=[];t["AJAX_MODE"]="Y";t["sessid"]=BX.bitrix_sessid();t["GET_INPUT"]="Y";t["PROPERTY_ID"]=e;t["ROW_ID"]=this.intIMAGE_ROW_ID;BX.ajax({method:"POST",dataType:"html",url:"/bitrix/admin/iblock_sub_generator.ajax.php",data:BX.ajax.prepareData(t),async:false,onsuccess:BX.proxy(this.fIblockInputResult,this)})};JCIBlockGenerator.prototype.disableControls=function(){var e;this.lockProperties=true;for(var t=0;t<this.AR_ALL_PROPERTIES.length;t++){if(BX("checked_all_"+t)){BX("checked_all_"+t).onclick=function(){return false}}e=document.getElementsByClassName("property_value_checkbox"+t);var a=e.length;for(var i=0;i<a;i++){if(e[i]){e[i].onclick=function(){return false};if(e[i].nextSibling.className=="adm-designed-checkbox-label"){if(e[i].checked)e[i].nextSibling.style.backgroundPosition="0 -3459px";else e[i].nextSibling.style.backgroundPosition="0 -1350px"}}}}var r=BX("ib_seg_select_prop_bar").querySelectorAll("select");[].forEach.call(r,function _(e){e.disabled=true});var s=BX(this.TABLE_PROP_ID).querySelectorAll("span.adm-shop-del-btn");[].forEach.call(s,function o(e){e.parentNode.innerHTML+=" "});if(BX("ib_seg_property_add_button_span_click")){BX("ib_seg_property_add_button_span_click").parentNode.innerHTML=""}if(BX("mnu_ADD_PROPERTY")){BX("mnu_ADD_PROPERTY").parentNode.innerHTML+=" "}};JCIBlockGenerator.prototype.addPropertyInTitle=function(e){var t=BX("IB_SEG_TITLE");if(t){t.value+=" "+e}};
//# sourceMappingURL=sub_generator.map.js